<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class AdminUserLog extends Model
{
    use HasFactory;

    protected $table = 'sp_other_admin_log';
    protected $primaryKey = 'id';
    public $timestamps = false;

    const OPERATION_TYPE_LOGIN = 1;//登录
    const OPERATION_TYPE_LOGIN_OUT = 2;//退出登录
    const OPERATION_TYPE_AUTH_USER = 3;//权限用户

    //根据member_id编辑供应商信息
    public static function addLog($admin_id,$operation_explain,$update_data,$operation_type)
    {
        $data = [];
        $data['admin_id'] = $admin_id;
        $data['operation_explain'] = $operation_explain;
        $data['operation_type'] = $operation_type;
        $data['update_data'] = json_encode($update_data);
        $data['user_agent'] =  $_SERVER['HTTP_USER_AGENT'];
        $data['user_ip'] = getRealIp();
        AdminUserLog::insert($data);
    }
}
